/*
 * The MiniQt Library
 *
 * Copyright (C) 1999 Sandro Sigala <ssigala@globalnet.it>
 */

#include <windows.h>

#include "qapplication.h"

QApplication *qApp;

struct QApplicationPrivate
{
	QWidget *main_widget;
	bool die;
};

QApplication::QApplication(int, char **)
	: QObject(0, "QApplication")
{
	d = new QApplicationPrivate;
	d->main_widget = 0;
	d->die = FALSE;
	qApp = this;
}

QApplication::~QApplication()
{
	delete d;
}

QWidget *QApplication::mainWidget()
{
	return d->main_widget;
}

void QApplication::setMainWidget(QWidget *w)
{
	d->main_widget = w;
}

int QApplication::exec()
{
	MSG msg;

	while (GetMessage(&msg, NULL, 0, 0) && !d->die) {
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return msg.wParam;
}

void QApplication::quit()
{
	// It's time to die
	d->die = TRUE;
}
